<foreach name="purpose" item="item">
	<div style="float:left" >
		<label><input class="purpose_big_{$item.id}" type="checkbox" name="purpose_id[]" value="{$item.id}" <if condition="$item['checked'] gt 0">checked="checked"</if>>{$item.name}：</label>
	</div>
	<div style="float:left;width:90%" class="purpose_sub">
		<?php  
		$num1=0; 
		$num2=0;?>
		<foreach name="item.sub" item="sub">
		<label><input rel="{$item.id}" type="checkbox" name="purpose_type_id[]" value="{$sub.id}" <if condition="$sub['checked'] gt 0">checked="checked"</if>>{$sub.name}</label>
		<if condition="$sub['checked'] eq 0">
			<?php  ++$num2; ?>
		</if>
		<?php  ++$num1; ?>
		</foreach>
		<input type="hidden" class="purpose_type_num1_{$item.id}" value="{$num1}">
		<input type="hidden" class="purpose_type_num2_{$item.id}" value="{$num2}">
	</div>
<div class="blank5"></div>
<div style="border-bottom:solid 1px #ccc;"></div>
</foreach>
<script type="text/javascript">
	$(".purpose_sub input").click(function(){
		var rel=$(this).attr("rel");
		var purpose_type_num1=parseInt($(".purpose_type_num1_"+rel).attr("value"),10);
		var purpose_type_num2=parseInt($(".purpose_type_num2_"+rel).attr("value"),10);
		if($(this).attr("checked")==true)
		{
			$(".purpose_big_"+rel).attr("checked",true);
			purpose_type_num2-=1;
			$(".purpose_type_num2_"+rel).attr("value",purpose_type_num2);
		}
		else{
			purpose_type_num2+=1;
			$(".purpose_type_num2_"+rel).attr("value",purpose_type_num2);
			if(purpose_type_num2==purpose_type_num1)
			$(".purpose_big_"+rel).attr("checked",false);
		}
	});
</script>